package com.quanxiaoha.weblog.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author: 犬小哈
 * @url: www.quanxiaoha.com
 * @date: 2024/2/21 18:28
 * @description: RestTemplate 配置
 **/
@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setConnectTimeout(60000); // 连接超时时间：60秒
        factory.setReadTimeout(300000); // 读取超时时间：300秒（5分钟，为AI API提供充足时间）
        return new RestTemplate(factory);
    }

}
